<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
export default {
  onLaunch: function() {
    console.log('App Launch')
    // 初始化应用
    this.initApp()
  },
  onShow: function() {
    console.log('App Show')
  },
  onHide: function() {
    console.log('App Hide')
  },
  methods: {
    initApp() {
      // 设置全局样式
      uni.setStorageSync('language', 'zh-CN')
      uni.setStorageSync('currency', 'USD')
      
      // 检查网络状态
      this.checkNetwork()
    },
    checkNetwork() {
      uni.getNetworkType({
        success: (res) => {
          console.log('网络类型:', res.networkType)
          if (res.networkType === 'none') {
            uni.showToast({
              title: '网络连接失败',
              icon: 'none',
              duration: 2000
            })
          }
        }
      })
    }
  }
}
</script>

<style>
/* 全局样式 */
page {
  background-color: #f8f8f8;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.container {
  padding: 20rpx;
}

/* 按钮样式 */
.primary-btn {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  border: none;
  border-radius: 50rpx;
  padding: 20rpx 40rpx;
  font-size: 32rpx;
  font-weight: 600;
}

.primary-btn:active {
  opacity: 0.8;
}

/* 卡片样式 */
.card {
  background: white;
  border-radius: 20rpx;
  padding: 30rpx;
  margin: 20rpx 0;
  box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
}

/* 输入框样式 */
.input {
  border: 2rpx solid #e0e0e0;
  border-radius: 12rpx;
  padding: 20rpx;
  font-size: 28rpx;
  background: white;
}

.input:focus {
  border-color: #ff6b6b;
  outline: none;
}

/* 标签样式 */
.tag {
  display: inline-block;
  padding: 8rpx 16rpx;
  border-radius: 20rpx;
  font-size: 24rpx;
  margin-right: 10rpx;
}

.tag-spicy {
  background: #ffeaa7;
  color: #d35400;
}

.tag-vegetarian {
  background: #55efc4;
  color: #00b894;
}

.tag-hot {
  background: #fab1a0;
  color: #e17055;
}

/* 价格样式 */
.price {
  color: #ff6b6b;
  font-weight: bold;
  font-size: 36rpx;
}

.original-price {
  color: #999;
  text-decoration: line-through;
  font-size: 28rpx;
  margin-left: 10rpx;
}

/* 加载动画 */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40rpx;
}

.loading-spinner {
  width: 40rpx;
  height: 40rpx;
  border: 4rpx solid #f3f3f3;
  border-top: 4rpx solid #ff6b6b;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 100rpx 0;
  color: #999;
}

.empty-icon {
  font-size: 120rpx;
  margin-bottom: 20rpx;
}

/* 响应式设计 */
@media (min-width: 768px) {
  .container {
    max-width: 750px;
    margin: 0 auto;
  }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
  page {
    background-color: #1a1a1a;
    color: white;
  }
  
  .card {
    background: #2d2d2d;
    box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.3);
  }
  
  .input {
    border-color: #404040;
    background: #2d2d2d;
    color: white;
  }
}
</style>